/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * InputQVFrame.java
 *
 * Created on 24/11/2009, 12:54:38
 */

package quantizacaovetorial;

import javax.swing.JFileChooser;
import javax.swing.JFrame;

/**
 *
 * @author Guto
 */
public class InputQVFrame extends javax.swing.JFrame {

    private JFileChooser jFileChooser;
    
    /** Creates new form InputQVFrame */
    public InputQVFrame() {
        initComponents();
        setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        painel = new javax.swing.JPanel();
        labelImageOriginal = new javax.swing.JLabel();
        txtImageOriginal = new javax.swing.JTextField();
        txtImageDestination = new javax.swing.JTextField();
        labelImageDestination = new javax.swing.JLabel();
        labelDimension = new javax.swing.JLabel();
        txtDimension = new javax.swing.JTextField();
        labelSizeDictionary = new javax.swing.JLabel();
        txtSizeDictionary = new javax.swing.JTextField();
        labelMethod = new javax.swing.JLabel();
        comboMethod = new javax.swing.JComboBox();
        bntSearch1 = new javax.swing.JButton();
        bntSearch2 = new javax.swing.JButton();
        bntQuantifyImage = new javax.swing.JButton();
        bntClean = new javax.swing.JButton();
        bntSearch3 = new javax.swing.JButton();
        txtDictionary = new javax.swing.JTextField();
        labelDictionary = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        painel.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

        labelImageOriginal.setText("Imagem Original:");

        txtImageDestination.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtImageDestinationActionPerformed(evt);
            }
        });

        labelImageDestination.setText("Imagem Destino:");

        labelDimension.setText("Dimensão:");

        txtDimension.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtDimensionActionPerformed(evt);
            }
        });

        labelSizeDictionary.setText("Tamanho do Dicionário:");

        txtSizeDictionary.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtSizeDictionaryActionPerformed(evt);
            }
        });

        labelMethod.setText("Método:");

        comboMethod.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "FS", "PDS" }));

        bntSearch1.setText("...");
        bntSearch1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bntSearch1ActionPerformed(evt);
            }
        });

        bntSearch2.setText("...");
        bntSearch2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bntSearch2ActionPerformed(evt);
            }
        });

        bntQuantifyImage.setText("Quantificar Imagem");
        bntQuantifyImage.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bntQuantifyImageActionPerformed(evt);
            }
        });

        bntClean.setText("Limpar Campos");
        bntClean.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bntCleanActionPerformed(evt);
            }
        });

        bntSearch3.setText("...");
        bntSearch3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bntSearch3ActionPerformed(evt);
            }
        });

        txtDictionary.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtDictionaryActionPerformed(evt);
            }
        });

        labelDictionary.setText("Dicionário:");

        javax.swing.GroupLayout painelLayout = new javax.swing.GroupLayout(painel);
        painel.setLayout(painelLayout);
        painelLayout.setHorizontalGroup(
            painelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(painelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(painelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(painelLayout.createSequentialGroup()
                        .addGroup(painelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(labelImageOriginal)
                            .addGroup(painelLayout.createSequentialGroup()
                                .addComponent(txtImageOriginal, javax.swing.GroupLayout.DEFAULT_SIZE, 525, Short.MAX_VALUE)
                                .addGap(10, 10, 10)
                                .addComponent(bntSearch1)
                                .addGap(51, 51, 51))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, painelLayout.createSequentialGroup()
                                .addComponent(bntClean)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 360, Short.MAX_VALUE)
                                .addComponent(bntQuantifyImage, javax.swing.GroupLayout.PREFERRED_SIZE, 166, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addContainerGap())
                    .addGroup(painelLayout.createSequentialGroup()
                        .addGroup(painelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(labelDictionary)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, painelLayout.createSequentialGroup()
                                .addComponent(txtDictionary, javax.swing.GroupLayout.DEFAULT_SIZE, 525, Short.MAX_VALUE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)))
                        .addGap(10, 10, 10)
                        .addComponent(bntSearch3)
                        .addGap(61, 61, 61))
                    .addGroup(painelLayout.createSequentialGroup()
                        .addGroup(painelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(labelImageDestination)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, painelLayout.createSequentialGroup()
                                .addGroup(painelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(txtImageDestination, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 525, Short.MAX_VALUE)
                                    .addComponent(labelMethod, javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, painelLayout.createSequentialGroup()
                                        .addGroup(painelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                            .addComponent(comboMethod, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                            .addComponent(labelDimension, javax.swing.GroupLayout.Alignment.LEADING)
                                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, painelLayout.createSequentialGroup()
                                                .addComponent(txtDimension, javax.swing.GroupLayout.PREFERRED_SIZE, 196, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 131, Short.MAX_VALUE)
                                        .addGroup(painelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(labelSizeDictionary)
                                            .addComponent(txtSizeDictionary, javax.swing.GroupLayout.PREFERRED_SIZE, 198, javax.swing.GroupLayout.PREFERRED_SIZE))))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)))
                        .addGap(10, 10, 10)
                        .addComponent(bntSearch2)
                        .addGap(61, 61, 61))))
        );
        painelLayout.setVerticalGroup(
            painelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(painelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(labelImageOriginal)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(painelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txtImageOriginal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(bntSearch1, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(painelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(painelLayout.createSequentialGroup()
                        .addComponent(labelDictionary)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtDictionary, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(2, 2, 2))
                    .addGroup(painelLayout.createSequentialGroup()
                        .addGap(21, 21, 21)
                        .addComponent(bntSearch3, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(painelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(painelLayout.createSequentialGroup()
                        .addComponent(labelImageDestination)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtImageDestination, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addGroup(painelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(painelLayout.createSequentialGroup()
                                .addComponent(labelDimension)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txtDimension, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(labelMethod)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(comboMethod, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(labelSizeDictionary)
                            .addGroup(painelLayout.createSequentialGroup()
                                .addGap(20, 20, 20)
                                .addComponent(txtSizeDictionary, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addGroup(painelLayout.createSequentialGroup()
                        .addGap(21, 21, 21)
                        .addComponent(bntSearch2, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 59, Short.MAX_VALUE)
                .addGroup(painelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(bntQuantifyImage)
                    .addComponent(bntClean))
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(painel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(87, 87, 87))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(57, 57, 57)
                .addComponent(painel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void txtImageDestinationActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtImageDestinationActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_txtImageDestinationActionPerformed

    private void txtDimensionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtDimensionActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_txtDimensionActionPerformed

    private void txtSizeDictionaryActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtSizeDictionaryActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_txtSizeDictionaryActionPerformed

    private void bntSearch1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bntSearch1ActionPerformed
        txtImageOriginal.setText(iniFileChooser());
}//GEN-LAST:event_bntSearch1ActionPerformed

    private void bntSearch2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bntSearch2ActionPerformed
        txtImageDestination.setText(iniFileChooser());
}//GEN-LAST:event_bntSearch2ActionPerformed

    private void bntQuantifyImageActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bntQuantifyImageActionPerformed
        ResultFrame resultFrame = new ResultFrame();
        resultFrame.openResultFrame();
}//GEN-LAST:event_bntQuantifyImageActionPerformed

    private void bntCleanActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bntCleanActionPerformed
        txtImageOriginal.setText(null);
        txtImageDestination.setText(null);
        txtDimension.setText(null);
        txtSizeDictionary.setText(null);
}//GEN-LAST:event_bntCleanActionPerformed

    private void bntSearch3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bntSearch3ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_bntSearch3ActionPerformed

    private void txtDictionaryActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtDictionaryActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtDictionaryActionPerformed

    private String iniFileChooser(){
        jFileChooser = new JFileChooser();
        JFrame frame = new JFrame();
        jFileChooser.setVisible(true);
        jFileChooser.showOpenDialog(frame);
        String path = "";
        if(jFileChooser.getSelectedFile()!=null){
            path = jFileChooser.getSelectedFile().getAbsolutePath();
        }
        return path;
    }

   public void openInputQVFrame(){
       InputQVFrame inputFrame = new InputQVFrame();
       inputFrame.setVisible(true);
       inputFrame.setLocationRelativeTo(null);
   }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton bntClean;
    private javax.swing.JButton bntQuantifyImage;
    private javax.swing.JButton bntSearch1;
    private javax.swing.JButton bntSearch2;
    private javax.swing.JButton bntSearch3;
    private javax.swing.JComboBox comboMethod;
    private javax.swing.JLabel labelDictionary;
    private javax.swing.JLabel labelDimension;
    private javax.swing.JLabel labelImageDestination;
    private javax.swing.JLabel labelImageOriginal;
    private javax.swing.JLabel labelMethod;
    private javax.swing.JLabel labelSizeDictionary;
    private javax.swing.JPanel painel;
    private javax.swing.JTextField txtDictionary;
    private javax.swing.JTextField txtDimension;
    private javax.swing.JTextField txtImageDestination;
    private javax.swing.JTextField txtImageOriginal;
    private javax.swing.JTextField txtSizeDictionary;
    // End of variables declaration//GEN-END:variables

}
